<?php
namespace app\home\controller;
use \think\Validate;
use \think\captcha\Captcha;
class Reg extends \think\Controller
{
    public function reg()
    {
        return view('reg');
    }

    public function reg_insert()
	{
		header("Content-Type:text/html;charset=utf8");
		$user_tell   = input('post.user_tell','','strip_tags');
		$user_pwd    = input('post.user_pwd');
		$user_repwd  = input('post.user_repwd');
		$data = [
		    'user_tell'   	=> $user_tell,
		    'user_pwd'    	=> $user_pwd,
		    'user_repwd'    => $user_repwd
		];

		$data = [
		    'user_tell'   	=> $user_tell,
		    'user_pwd'    	=> md5($user_pwd),
		    'user_addtime'  => time()
		];

		$ret = db('user')->insert($data);  //插入数据到数据表user
		if($ret ==false)
		{
			$this->error("注册失败！");
		}
		$this->success("注册成功！","/home/login/login");
	}


    public function verify()
	{
		$config =    [
		    // 验证码字体大小
		    'fontSize'    =>    30,
		    // 验证码位数
		    'length'      =>    4,
		    // 关闭验证码杂点
		    'useNoise'    =>    false,
		];
		$captcha = new Captcha($config);
		return $captcha->entry();
	}

}
